-- 警告:
-- 数值设定见 modmain/tuning.lua
-- 请勿使用“记事本”修改代码，否则可能会发生游戏崩溃
-- 推荐选择 Visual Studio Code，Sublime Text 4 等正经的代码编辑器

GLOBAL.setmetatable(env,{__index=function(t,k) return GLOBAL.rawget(GLOBAL,k) end})

GLOBAL.HOMURA_GLOBALS = 
{
    SKILLKEY = GetModConfigData("skillkey") + 32,
    SKILLKEY_STRING = string.char(GetModConfigData("skillkey")),
    PLAYERDMG = GetModConfigData("playerdmg") or TheNet:GetPVPEnabled(),
}

if GLOBAL.HOMURA_GLOBALS.SKILLKEY > 122 then 
    GLOBAL.HOMURA_GLOBALS.SKILLKEY = GLOBAL.HOMURA_GLOBALS.SKILLKEY - 32
elseif GLOBAL.HOMURA_GLOBALS.SKILLKEY < 97 then 
    GLOBAL.HOMURA_GLOBALS.SKILLKEY = GLOBAL.HOMURA_GLOBALS.SKILLKEY + 32 
end

Assets =
{
    Asset("ATLAS", "images/hud/homuraUI_mover.xml"),

    Asset("ANIM", "anim/puellaUI_flash.zip"),
    Asset("ANIM", "anim/puellaUI_homurafocus.zip"),

    Asset("ANIM", "anim/lw_player_pistol.zip"),
    Asset("ANIM", "anim/homura_gun_fire.zip"),

    Asset("ANIM", "anim/homura_buff_base.zip"),
    Asset("ATLAS", "images/homura_weapon_buff.xml"),
    Asset('ATLAS_BUILD',"images/homura_weapon_buff.xml", 64),

    Asset("SOUNDPACKAGE", "sound/lw_homura.fev"),
    Asset("SOUND", "sound/lw_homura.fsb"),

    -- skin
    Asset("ANIM", 'anim/homura_0.zip'),
    Asset("ANIM" ,'anim/homuraUI_skinbg.zip'),
}

PrefabFiles = {
    "homura_1",       
    "homura_rpg",
    'homura_workdesk',
    'homura_clock',
    'homura_bombs',
    'homura_pistol',
    'homura_weapon_buffs',

    'homura_fake_target',
}

modimport "modmain/tuning.lua"      -- 数值设定 
modimport "modmain/language.lua"    -- 语言设定
modimport "modmain/puella_fn.lua"   -- 做mod常用的函数 -
modimport "modmain/rpc.lua"         -- 客户端通讯 -
modimport "modmain/newtech.lua"     -- 晓美焰专属科技（枪 子弹 配件 炸弹 火箭筒）
modimport "modmain/constants.lua"   -- 新的常量
modimport "modmain/recipes.lua"     -- 新配方
modimport "modmain/API.lua"         -- 钩子 -
modimport "modmain/timemagic.lua"   -- 时停 -
modimport "modmain/net.lua"         -- 网络变量 √
modimport "modmain/ui.lua"          -- 技能按钮
modimport "modmain/key.lua"         -- 技能快捷键 √
modimport "modmain/actions.lua"     -- 新动作
modimport "modmain/SGmain.lua"      -- 修改人物sg, 添加各种新的攻击类型 
modimport "modmain/container.lua"   -- 新容器 √
modimport "modmain/detonator.lua"   -- 雷管 √
modimport "modmain/gunpowder.lua"   -- 分支合成 √
modimport "modmain/sgrecorder.lua"  -- 保证在时停期间不进入新sg
modimport 'modmain/skins.lua'       -- 眼镜焰皮肤 
modimport "modmain/postprocess.lua" -- 后处理 √

--modimport "modmain/debugfunctions.lua"
-- modimport "modmain/debug.lua"

local name = "homura_1"
table.insert(Assets, Asset( "ATLAS", "bigportraits/homura_1_moe.xml" ))
table.insert(Assets, Asset( "ATLAS", "bigportraits/homura_1_none.xml" ))

table.insert(Assets,Asset( "ATLAS", "images/saveslot_portraits/"..name..".xml" ))
table.insert(Assets,Asset( "ATLAS", "images/selectscreen_portraits/"..name..".xml" ))
--table.insert(Assets,Asset( "ATLAS", "bigportraits/"..name..".xml" ))
table.insert(Assets,Asset( "ATLAS", "images/map_icons/"..name..".xml"))
table.insert(Assets,Asset( "ATLAS", "images/avatars/avatar_"..name..".xml"))
table.insert(Assets,Asset( "ATLAS", "images/avatars/avatar_ghost_"..name..".xml"))
table.insert(Assets,Asset( "ATLAS", "images/avatars/self_inspect_"..name..".xml"))
table.insert(Assets,Asset( "ATLAS", "images/names_"..name..".xml"))
table.insert(Assets,Asset( "ATLAS", "bigportraits/"..name.."_none.xml"))
table.insert(Assets,Asset( "ANIM" , "anim/"..name..".zip"))
table.insert(Assets,Asset( "ANIM" , "anim/ghost_"..name.."_build.zip"))
table.insert(CHARACTER_GENDERS.FEMALE, name)

--感谢bowcar提供的台词文件
STRINGS.CHARACTERS[string.upper(name)] = L and deepcopy(require 'speech_wilson') or require 'speech_homura_ch'

AddMinimapAtlas("images/map_icons/"..name ..".xml")
AddModCharacter(name)

local chardata = L and 
{
    {
        prefab = "homura_1",
        T = "Mysterious transfer student",
        N = "Homura Akemi",
        D = "*Masters making munitions.\n*Can control time.", 
        Q = "\"No one believe the future, no one accept the truth about future...\"",
    },
}
or 
{
    {
        prefab = "homura_1",
        T = "神秘的转校生",
        N = "晓美焰",
        D = "*制造和使用热兵器。\n*掌握控制时间的魔法。",
        Q = "\"谁都, 不会相信未来, 谁都, 无法接受未来, 那样的话，我就...\"",

    },
}

for _, data in pairs(chardata)do
    STRINGS.CHARACTER_TITLES[data.prefab] = data.T
    STRINGS.CHARACTER_NAMES[data.prefab] = data.N
    STRINGS.NAMES[data.prefab:upper()] = data.N
    STRINGS.CHARACTER_DESCRIPTIONS[data.prefab] = data.D
    STRINGS.CHARACTER_QUOTES[data.prefab] = data.Q
end

modimport "modmain/strings.lua"
